import request from "@/utils/request";

export default {
    //查询商品类型  {gname,typeId,kid} 查询条件
    getgoods({gname,typeId,kid}) {
        // console.log(gname,typeId,kid);
        return request({
            method: "get",
            url: "/goods/searchgoods",
            params:{
                gname,
                typeId,
                kid
            }
        })
    },
    // 分页查询总商品类型,
    // page当前页码, size 每页显示条数, 
    // 后台要通过 page 和 size 统计本次请求响应的数据
    searchgoods(page, size) {
        return request({
            url: `/goods/padinggoods`,
            method: "get",
            params: {
                page,
                size
            }
        })
    },
    //增加新类型
    addgoods({gname,typeId,kid,gimg,gprice,gstock}) {
        return request({
            url: `/goods/addgood/`+typeId+'/'+kid,
            method: "post",
            data: {
                gname,
                gimg,
                gprice,
                gstock
            }
        })
    },
    //更新类型信息
    updatatype(gid,{gname,typeId,kid,gimg,gprice,gstock}){
        return request({
            url:`/goods/editgood/${gid}`,
            method:"put",
            data:{
                gname,
                typeId,
                kid,
                gimg,
                gprice,
                gstock
            }
        })
    },
    //删除类型
    delgoods(gid){
        return request({
            url:`/goods/delgood`,
            method:'delete',
            data:{
                gid
            }
        })
    }
}